import { Injectable } from "@angular/core"
import { LoginUser } from "./login-user"
import { HttpClient } from "@angular/common/http"
import { Result } from "src/common/result"
export interface User {
  id: number
  name: string
}
//可注入的
@Injectable({
  providedIn: "root",
})
export class UserService {
  url = "/api/users/"
  //依赖注入
  constructor(private http: HttpClient) {}
  login(user: LoginUser) {
    return this.http.post<Result<User>>(this.url + "login", user)
  }
  getCodeImg() {
    return this.http.get<Result<string>>(this.url + "code-img")
  }
}

//app.module.ts导入 httpCLientModule
